In [1]:
from sympy import *
init_printing() #muestra símbolos más agradab
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import numpy as np
R=lambda n,d: Rational(n,d)

Ejercicio 2. Encntrar coordenadas canónicas para las simetrías

Inciso $a)$


In [2]:
x,y,epsilon=symbols('x,y,epsilon',real=true)
xc,yc=symbols('\hat{x},\hat{y}')
xi,eta=symbols('xi,eta')
C=symbols('C')

simetrias=(x+epsilon,y)

xi=simetrias[0].diff(epsilon).subs(epsilon,0) 
eta=simetrias[1].diff(epsilon).subs(epsilon,0) 
xi, eta

yaux=integrate(eta/xi,y)+C
r=solve(y-yaux,C)[0]

s=integrate(1/(xi),x).subs(y,r)
r, s


Out[2]:
$$\left ( y, \quad x\right )$$

In [3]:
#VERIFICAMOS QUE SEAN CANONICAS


(r,s), (r.subs(x,simetrias[0]).subs(y,simetrias[1]),s.subs(x,simetrias[0]).subs(y,simetrias[1]))


Out[3]:
$$\left ( \left ( y, \quad x\right ), \quad \left ( y, \quad \epsilon + x\right )\right )$$

Inciso $b)$


In [4]:
simetrias=(exp(epsilon)*x,y)

xi=simetrias[0].diff(epsilon).subs(epsilon,0) 
eta=simetrias[1].diff(epsilon).subs(epsilon,0) 
xi, eta

yaux=integrate(eta/xi,y)+C
r=solve(y-yaux,C)[0]

s=integrate(1/(xi),x)
r, s


Out[4]:
$$\left ( y, \quad \log{\left (x \right )}\right )$$

In [5]:
#VERIFICAMOS QUE SEAN CANONICAS


(r,s), (r.subs(x,simetrias[0]).subs(y,simetrias[1]),s.subs(x,simetrias[0]).subs(y,simetrias[1]))


Out[5]:
$$\left ( \left ( y, \quad \log{\left (x \right )}\right ), \quad \left ( y, \quad \log{\left (x e^{\epsilon} \right )}\right )\right )$$

Inciso $c)$


In [6]:
xc=x/(1-epsilon*x)
yc=y/(1-epsilon*x)
simetrias=(xc,yc)


xi=simetrias[0].diff(epsilon).subs(epsilon,0) 
eta=simetrias[1].diff(epsilon).subs(epsilon,0) 
xi, eta


Out[6]:
$$\left ( x^{2}, \quad x y\right )$$

In [7]:
#entontramos r
z=Function('z')(x)
dsolve(Eq(z.diff(x),z/x),z)
#r=y/x

r=y/x

s=integrate(1/(xi),x)

r,s


Out[7]:
$$\left ( \frac{y}{x}, \quad - \frac{1}{x}\right )$$

In [8]:
#VERIFICAMOS QUE SEAN CANONICAS
rr=r.subs(y,yc).subs(x,xc)
ss=s.subs(y,yc).subs(x,xc).simplify()
r, s, rr, ss


Out[8]:
$$\left ( \frac{y}{x}, \quad - \frac{1}{x}, \quad \frac{y \left(- \epsilon x + 1\right)}{x \left(- \frac{\epsilon x}{- \epsilon x + 1} + 1\right)}, \quad \epsilon - \frac{1}{x}\right )$$

Inciso $d)$


In [9]:
x,y,epsilon=symbols('x,y,epsilon')
xc,yc=symbols('\hat{x},\hat{y}')
xi,eta=symbols('xi,eta')
C=symbols('C')


xc=cos(epsilon)*x-sin(epsilon)*y
yc=sin(epsilon)*x+cos(epsilon)*y
simetrias=(xc,yc)

xi=simetrias[0].diff(epsilon).subs(epsilon,0) 
eta=simetrias[1].diff(epsilon).subs(epsilon,0) 
xi, eta


Out[9]:
$$\left ( - y, \quad x\right )$$

In [10]:
#buscamos r
z=Function('z')(x)
ecuacion=Eq(z.diff(x)+x/z,0)

zz=dsolve(ecuacion,z)

y=symbols('y')
r=sqrt(x**2+y**2)
r

r0=symbols('r',positive=true)
s=integrate(-1/sqrt(r0**2-x**2),x)
r, s
#RESUELVO SÓLO CON LA COMPU
#ecuacion=Eq(y.diff(x)-eta/xi,0)
#ecuacion
#r=dsolve(ecuacion,y)
#r

#s=integrate(1/(r[1].rhs),x)
#r,s
##########################################


#yaux=integrate(eta/xi,y)+C
#r=solve(y-yaux,C)[0]
#xi,eta,yaux
#s=integrate(1/(xi),x).subs(y,r)
#r,s


Out[10]:
$$\left ( \sqrt{x^{2} + y^{2}}, \quad - \operatorname{asin}{\left (\frac{x}{r} \right )}\right )$$

In [11]:
zz


Out[11]:
$$\left [ z{\left (x \right )} = - \sqrt{C_{1} - x^{2}}, \quad z{\left (x \right )} = \sqrt{C_{1} - x^{2}}\right ]$$

In [12]:
#VERIFICAMOS QUE SEAN CANONICAS
rr=r.subs(y,yc).subs(x,xc)
ss=s.subs(y,yc).subs(x,xc).simplify()
r**2, s, rr**2, ss


Out[12]:
$$\left ( x^{2} + y^{2}, \quad - \operatorname{asin}{\left (\frac{x}{r} \right )}, \quad \left(x \cos{\left (\epsilon \right )} - y \sin{\left (\epsilon \right )}\right)^{2} + \left(y \cos{\left (\epsilon \right )} + \left(x \cos{\left (\epsilon \right )} - y \sin{\left (\epsilon \right )}\right) \sin{\left (\epsilon \right )}\right)^{2}, \quad - \operatorname{asin}{\left (\frac{1}{r} \left(x \cos{\left (\epsilon \right )} - y \sin{\left (\epsilon \right )}\right) \right )}\right )$$

Ejercicio 2


In [13]:
x,y,epsilon=symbols('x,y,epsilon',real=true)
xc,yc=symbols('\hat{x},\hat{y}')
xi,eta=symbols('xi,eta')
C=symbols('C')


sin(epsilon+atan(x))/(cos(epsilon+atan(x)))

(sin(epsilon)*cos(atan(x))+cos(epsilon)*sin(atan(x)))/(cos(epsilon)*cos(atan(x))-sin(epsilon)*sin(atan(x))).simplify().factor()

y/((cos(epsilon)*cos(atan(x))-sin(epsilon)*sin(atan(x)))*sqrt(1+x**2)).expand()


Out[13]:
$$\frac{y}{- x \sin{\left (\epsilon \right )} + \cos{\left (\epsilon \right )}}$$

Ejercicio 3

Ejercicio 1.1


In [14]:
x,y,epsilon=symbols('x,y,epsilon')
xc,yc=symbols('\hat{x},\hat{y}')
xi,eta=symbols('xi,eta')
C=symbols('C')
y=Function('y')(x)

xc=cos(epsilon)*x-sin(epsilon)*y
yc=sin(epsilon)*x+cos(epsilon)*y
simetrias=(xc,yc)
simetrias

exp0=(yc.diff(x)/xc.diff(x)).subs(y.diff(x),y/x)
y=symbols('y')
(exp0.subs(y(x),y)).factor()


Out[14]:
$$\frac{x \sin{\left (\epsilon \right )} + y \cos{\left (\epsilon \right )}}{x \cos{\left (\epsilon \right )} - y \sin{\left (\epsilon \right )}}$$

Ejercicio 1.2


In [15]:
x,y,epsilon=symbols('x,y,epsilon',real=true)
Y=Function('Y')(x)
sol=dsolve(Eq(Y.diff(x)-(1-Y**2)/x),Y)
sol


Out[15]:
$$Y{\left (x \right )} = \frac{C_{1} + x^{2}}{- C_{1} + x^{2}}$$

Ejercicio 1.5


In [16]:
f=3*y/x+x**5/(x**3+2*y)
y=Function('y')(x)
r=y/x**3 
s=log(x)
r, s
exp0=s.diff(x)/r.diff(x)
exp1=exp0.subs(y.diff(x), f)
exp1.expand()


Out[16]:
$$\frac{1}{\frac{x^{3}}{x^{3} + 2 y} + \frac{3 y}{x^{3}} - \frac{3}{x^{3}} y{\left (x \right )}}$$

Ejercicio 1.6


In [17]:
a,b,c,d=symbols('a,b,c,d',real=true)
x,y=symbols('x,y',real=true)
#f=exp(-x)*y**2+y+exp(x)
xi=a*x+b*y
eta=c*x+d*y
xi, eta
f=exp(-x)*y**2+y+exp(x)
expr0=eta.diff(x)+(eta.diff(y)-xi.diff(x))*f-xi.diff(y)*f**2-xi*f.diff(x)-eta*f.diff(y)
expr1=expr0.expand().factor().collect(exp(x))
expr1, f


Out[17]:
$$\left ( \left(- b y^{4} - b e^{4 x} + \left(- a x - a - 3 b y + d\right) e^{3 x} + \left(- a y - 3 b y^{2} - c x + c\right) e^{2 x} + \left(a x y^{2} - a y^{2} - b y^{3} - 2 c x y - d y^{2}\right) e^{x}\right) e^{- 2 x}, \quad y^{2} e^{- x} + y + e^{x}\right )$$

Ejercicio 2.2


In [18]:
#SUPONEMOS x>0 y>0

#CALCULAMOS r Y s



#y>0 x>0
y=symbols('y',positive=true)
x=symbols('x',positive=true)


r=y**2/x+x
#r
s=-1/r*sqrt((r-x)/x)
#r.factor(),s.expand()
r,s.factor()


Out[18]:
$$\left ( x + \frac{y^{2}}{x}, \quad - \frac{y}{x^{2} + y^{2}}\right )$$

In [19]:
#resolvemos la ecuacion de las coordenadas canónicas para encontrar las simetrías ( es decir xc e yc)
#reiniciamos el valor de x,y,xc,yc por las dudas que tengan otros valores que prvengan de otros ejercicios




xc,yc=symbols('\hat{x},\hat{y}')
eq1=Eq(r.subs(x,xc).subs(y,yc),r)
eq2=Eq(s.subs(x,xc).subs(y,yc),s+epsilon)


sol=solve([eq1,eq2],[xc,yc])

sol


Out[19]:
$$\left [ \left ( \frac{x}{\epsilon^{2} x^{2} + \epsilon^{2} y^{2} - 2 \epsilon y + 1}, \quad \frac{- \epsilon x^{2} - \epsilon y^{2} + y}{\epsilon^{2} x^{2} + \epsilon^{2} y^{2} - 2 \epsilon y + 1}\right )\right ]$$

In [20]:
#VERIFICAMOS QUE SON REALMENTE LAS SIMETRÍAS
sol[0][0].diff(epsilon).subs(epsilon,0), sol[0][1].diff(epsilon).subs(epsilon,0)


Out[20]:
$$\left ( 2 x y, \quad - x^{2} + y^{2}\right )$$

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: